package algorithm;

/**
 * 项目名称：Demo01
 * 类 名 称：BubblingAlgorithm
 * 类 描 述：TODO
 * 创建时间：2021/03/10 10:15
 * 创 建 人：XiaoCoder
 */
public class BubblingAlgorithm {
    public static void main(String[] args) {
        int[] ar = {1, 3, 12, 31, 21, 13, 14};
        for (int i = 0; i < ar.length - 1; i++) {
            for (int j = i; j < ar.length - 1 - i; j++) {
                if (ar[j] > ar[j + 1]) {
                    int tem = ar[j];
                    ar[j] = ar[j + 1];
                    ar[j + 1] = tem;
                }
            }
        }
        System.out.println("结果如下：");
        for (int i : ar) {
            System.out.print(i + " ");
        }
    }
}
